package ru.dc.object.commands;

/**
 * <h3>Syntax</h3>
 * <pre>$MyNick &lt;username>|</pre>
 * <h3>Description</h3>
 * <ul>
 * <li>The first command to be sent when connecting to a user.</li>
 * <li>The $Lock command should be sent next.</li>
 * </ul>
 * <h3>Peculiarities</h3>
 * <ul><li>DC++ checks if the username matches one of the usernames in any hubs that the user is in.
 * If no such user is found, DC++ disconnects immediately.</li></ul>
 */
public class MyNick extends Command {

    private String nick;

    @Override
    public String getActualCommandName() {
        return "$MyNick";
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }

    @Override
    public String generateCommand() {
        return getActualCommandName()+" "+nick;
    }

    @Override
    public void parseCommand() {
        if (getCommand().length()>8) {
            setNick(getCommand().substring(8));
        }
        else {
            setNick(null);
        }
    }
}
